package com.richard.single;

//enum  是一个什么？本身也是一个Class类

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public enum EnumSingle {

    INSTANCE ;

    public EnumSingle getInstance(){
        return INSTANCE;
    }


    static class Test{
        public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
           EnumSingle instance1 = EnumSingle.INSTANCE;
            Constructor<EnumSingle> declaredConstructor = EnumSingle.class.getDeclaredConstructor(String.class,int.class);
            declaredConstructor.setAccessible(true);
            EnumSingle instance2 = declaredConstructor.newInstance();

            //java.lang.NoSuchMethodException: com.richard.single.EnumSingle.<init>()
            System.out.println(instance1);
            System.out.println(instance2);
        }
    }

}
